package com.victualler.product.customer.controller.impl;

import com.victualler.core.base.controller.impl.BaseRestControllerImpl;
import com.victualler.core.common.dto.PageDto;
import com.victualler.product.customer.controller.CustomerController;
import com.victualler.product.customer.dto.CustomerInfoDto;
import com.victualler.product.customer.dto.request.CustomerReqeustDto;
import com.victualler.product.customer.entity.CustomerDao;
import com.victualler.product.customer.repository.CustomerQueryRepository;
import com.victualler.product.customer.repository.CustomerRepository;
import com.victualler.product.customer.service.CustomerService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Guoshichang
 * @discription:    
 */
@RestController
@RequestMapping("/product/customer")
public class CustomerControllerImpl extends BaseRestControllerImpl<CustomerDao,CustomerRepository,CustomerQueryRepository,CustomerService> implements CustomerController {



    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param customerReqeustDto 请求对象
     * @Function  根据条件入参customerReqeustDto动态分页查询权限
     */
    @RequestMapping("/getByRequestDto")
    public PageDto<CustomerDao> getByRequestDto(@RequestBody CustomerReqeustDto customerReqeustDto, @RequestParam("pageNo") int pageNo, @RequestParam("limit") int limit) {
        return this.baseService.getByRequestDto(customerReqeustDto,pageNo,limit);
    }

    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param id
     * @Function 根据id获取所有信息
     */
    @RequestMapping("/findInfoDto/{id}")
    @Override
    public CustomerInfoDto findInfoDto(@PathVariable("id") Long id) {
        return this.baseService.findInfoDto(id);
    }

    /**
     * @author Guoshichang
     * @since 13:58 on 2019/1/16.
     * @param openId 微信对应的id号
     * @return  对应的客户详细信息
     * @Function 根据微信唯一标识确定
     */
    @RequestMapping("/findInfoDtoByOpenId/{openId}")
    public CustomerInfoDto findInfoDtoByOpenId(@PathVariable("openId") String openId) {
        return this.baseService.findInfoDtoByOpenId(openId);
    }

    /**
     * @author Guoshichang
     * @since 13:58 on 2019/1/16.
     * @return  对应的客户详细信息
     * @Function 根据微信唯一标识确定
     */
    @RequestMapping("/bindCustomerByWeiXin")
    public CustomerInfoDto bindCustomerByWeiXin(@RequestBody CustomerDao customerDao) {
        return this.baseService.bindCustomerByWeiXin(customerDao);
    }


    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param customerInfoDto 全部信息
     * @Function 保存大对象
     */
    @RequestMapping("/saveInfo")
    @Override
    public void saveInfo(@RequestBody CustomerInfoDto customerInfoDto) {
        this.baseService.saveInfo(customerInfoDto);
    }
}
